package com.ruoyi.hqfinance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.hqfinance.domain.HqTransferBubbleSheetBySentNum;
import com.ruoyi.hqfinance.domain.HqTransferBubbleSheetPreAdjust;
import com.ruoyi.hqfinance.domain.vo.HqTransferBubbleSheetVo;
import com.ruoyi.hqfinance.service.HqTransferBubbleSheetService;
import com.ruoyi.logistic.domain.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hq/transferBubble")
@Api(tags = "总部财务-中转计泡报表")
public class HqTransferBubbleSheetController {
    @Autowired
    private HqTransferBubbleSheetService hqTransferBubbleSheetService;

    @ApiOperation("汇总预收+调整")
    @PostMapping("/collectPreAdjust")
    public R collectPreAdjust(@RequestBody HqTransferBubbleSheetVo vo){
        if (vo.getCollectTime() == null || vo.getCollectType() == null || vo.getStartTime() == null || vo.getEndTime() == null || vo.getNetworkNameId() == null){
            return R.fail("请传入汇总所需要的参数！");
        }
        List<HqTransferBubbleSheetPreAdjust> preAdjustList = hqTransferBubbleSheetService.collectPreAdjust(vo);
        if (preAdjustList == null || preAdjustList.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(preAdjustList));
        }
    }

    @ApiOperation("汇总按发件量统计")
    @PostMapping("/collectBySentNum")
    public R collectBySentNum(@RequestBody HqTransferBubbleSheetVo vo){
        if (vo.getCollectTime() == null || vo.getCollectType() == null || vo.getStartTime() == null || vo.getEndTime() == null || vo.getNetworkNameId() == null){
            return R.fail("请传入汇总所需要的参数！");
        }
        List<HqTransferBubbleSheetBySentNum> sheetBySentNums = hqTransferBubbleSheetService.collectBySentNum(vo);
        if (sheetBySentNums == null || sheetBySentNums.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(sheetBySentNums));
        }
    }

}
